package com.qianyu.project.mapper.provider.smj;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface smjFragmentaryDao {
    //添加零星劳务单
    @Insert("insert into fragmentary(id, apply_date, p_id, type, handler_id, comment, attach_ids)" +
            " value(#{id},#{apply_date},#{p_id},#{type},#{handler_id},#{comment},#{attach_ids})")
    void AddFragmentary(String id,String apply_date, String p_id, String type, String handler_id, String comment, String attach_ids);

    //添加
    @Insert("insert into fragmentary_work_list values(null,#{fragmentary_id}, #{work_content}, #{unit}, #{unit_price}, #{number},#{sumnumber})")
    void AddWorkList(String fragmentary_id, String work_content, String unit, String unit_price, String number,String sumnumber);

    @Update("update fragmentary set approve_status =#{approve_status} where id =#{id}")
    void UpdateApproveStatus(int approve_status, String id);

    //获取零星劳务列表
    @SelectProvider(type=smjFragmentaryProvider.class,method = "ListFragmentary")
    IPage<Map<String, Object>> ListFragmentary(IPage<Map<String, Object>> page, Map<String, String> params);

    //获取工程量清单
    @Select("select * from fragmentary_work_list where fragmentary_id=#{fragmentary_id}")
    List<Map<String, Object>> getWorkList(String fragmentary_id);

    //获取流程id
    @Select("select fid from form  where id=#{id} and target ='fragmentary'")
    String getFid(String id);

    //获取审批流程
    @Select("select fa.*,fn.flowNodeName,su.user_realname from form_audit fa ,flow_node fn ,system_user su where fa.fid=#{fid} and fa.flowNodeId = fn.flowNodeId and fa.eid=su.id")
    List<Map<String, Object>> getfromaudit(String fid);
}
